<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-sys__payconfig}">
      <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
        <el-form-item>
          <el-input v-model="dataForm.id" placeholder="id" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-button @click="getDataList()">{{ $t('query') }}</el-button>
        </el-form-item>
        <el-form-item>
          <el-button type="info" @click="exportHandle()">{{ $t('export') }}</el-button>
        </el-form-item>
        <el-form-item>
          <el-button v-if="$hasPermission('sys:payconfig:save')" type="primary" @click="addOrUpdateHandle()">{{ $t('add') }}</el-button>
        </el-form-item>
        <el-form-item>
          <el-button v-if="$hasPermission('sys:payconfig:delete')" type="danger" @click="deleteHandle()">{{ $t('deleteBatch') }}</el-button>
        </el-form-item>
      </el-form>
      <el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle" style="width: 100%;">
        <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
        <el-table-column prop="appId" :label="$t('payconfig.appId')" :show-overflow-tooltip="true" header-align="center" align="center"></el-table-column>
        <el-table-column prop="merchantId" :label="$t('payconfig.merchantId')" header-align="center" width="150" align="center"></el-table-column>
        <el-table-column prop="appSecret" :label="$t('payconfig.appSecret')" :show-overflow-tooltip="true" width="200" header-align="center" align="center"></el-table-column>
        <el-table-column prop="privateKey" :label="$t('payconfig.privateKey')" :show-overflow-tooltip="true" width="200" header-align="center" align="center"></el-table-column>
        <el-table-column prop="publicKey" :label="$t('payconfig.publicKey')" :show-overflow-tooltip="true" width="200" header-align="center" align="center"></el-table-column>
        <el-table-column prop="payUrl" :label="$t('payconfig.payUrl')" :show-overflow-tooltip="true" header-align="center" width="200" align="center"></el-table-column>
        <el-table-column prop="payUrlMontage" :label="$t('payconfig.payUrlMontage')" :show-overflow-tooltip="true" width="200" header-align="center" align="center"></el-table-column>
        <el-table-column prop="notifyUrl" :label="$t('payconfig.notifyUrl')" :show-overflow-tooltip="true" width="200" header-align="center" align="center"></el-table-column>
        <el-table-column prop="returnUrl" :label="$t('payconfig.returnUrl')" :show-overflow-tooltip="true" width="200" header-align="center" align="center"></el-table-column>
        <el-table-column prop="merchantsName" :label="$t('payconfig.merchantsName')" header-align="center" align="center"></el-table-column>
        <el-table-column prop="payName" :label="$t('payconfig.payName')" header-align="center" align="center"></el-table-column>
        <el-table-column prop="type" :label="$t('payconfig.type')" sortable="custom" header-align="center" align="center">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.type === 1" size="small">{{ $t('payconfig.type1') }}</el-tag>
            <el-tag v-if="scope.row.type === 2" size="small" type="success">{{ $t('payconfig.type2') }}</el-tag>
            <el-tag v-if="scope.row.type === 3" size="small" type="success">{{ $t('payconfig.type3') }}</el-tag>
            <el-tag v-if="scope.row.type === 4" size="small" type="success">{{ $t('payconfig.type4') }}</el-tag>
            <el-tag v-if="scope.row.type === 6" size="small" type="success">{{ $t('payconfig.type6') }}</el-tag>
            <el-tag v-if="scope.row.type === 7" size="small" type="success">{{ $t('payconfig.type7') }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="status" :label="$t('payconfig.status')" sortable="custom" header-align="center" align="center">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.status === 1" size="small" type="success">{{ $t('payconfig.status1') }}</el-tag>
            <el-tag v-else size="small" type="info">{{ $t('payconfig.status2') }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="amountSuccess" :label="$t('payconfig.amountSuccess')" header-align="center" align="center"></el-table-column>
        <el-table-column prop="remark" :label="$t('payconfig.remark')" header-align="center" align="center"></el-table-column>
        <el-table-column prop="callName" :label="$t('payconfig.callName')" header-align="center" align="center"></el-table-column>
        <el-table-column prop="icon" :label="$t('payconfig.icon')" :show-overflow-tooltip="true" header-align="center" align="center">
          <template slot-scope="scope">
          <!-- <img :src="scope.row.makeCollectionsUrl" width="60" height="60" alt=""/> -->
          <el-image
              @click="
                bigImg(scope.row.icon)
              "
              style="width: 50px; height: 50px; margin-bottom:-4px"
              :src="scope.row.icon"
              :preview-src-list="srcList"
            >
          </el-image>
        </template>
        </el-table-column>
        <el-table-column prop="appAppidCode" :label="$t('payconfig.appAppidCode')" header-align="center" align="center"></el-table-column>
        <el-table-column prop="appSecretCode" :label="$t('payconfig.appSecretCode')" header-align="center" align="center"></el-table-column>
        <el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150">
          <template slot-scope="scope">
            <el-button v-if="$hasPermission('sys:payconfig:update')" type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">{{ $t('update') }}</el-button>
            <el-button v-if="$hasPermission('sys:payconfig:delete')" type="text" size="small" @click="deleteHandle(scope.row.id)">{{ $t('delete') }}</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        :current-page="page"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="limit"
        :total="total"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="pageSizeChangeHandle"
        @current-change="pageCurrentChangeHandle">
      </el-pagination>
      <!-- 弹窗, 新增 / 修改 -->
      <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
    </div>
  </el-card>
</template>

<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './payconfig-add-or-update'
export default {
  mixins: [mixinViewModule],
  data () {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/sys/payconfig/page',
        getDataListIsPage: true,
        exportURL: '/sys/payconfig/export',
        deleteURL: '/sys/payconfig',
        deleteIsBatch: true
      },
      srcList: ["https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg"],
      dataForm: {
        id: ''
      }
    }
  },
    methods: {
      bigImg(url) {
        this.srcList[0] = url;
      }
    },
  components: {
    AddOrUpdate
  }
}
</script>